import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },

  {
    path: '/category',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Category',
        component: () => import('@/views/category/index'),
        meta: { title: '栏目管理', icon: 'form' }
      }
    ]
  },

  {
    path: '/product',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Product',
        component: () => import('@/views/product/index'),
        meta: { title: '产品管理', icon: 'form' }
      }
    ]
  },

  {
    path: '/order',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Order',
        component: () => import('@/views/order/index'),
        meta: { title: '订单管理', icon: 'form' }
      }
    ]
  },

  {
    path: '/check',
    component: Layout,
    meta: { title: '审核大厅', icon: 'form' },
    children: [
      {
        path: 'certification',
        name: 'Certification',
        component: () => import('@/views/check/certification'),
        meta: { title: '实名认证', icon: 'form' }
      },
      {
        path: 'accountApply',
        name: 'AccountApply',
        component: () => import('@/views/check/accountApply'),
        meta: { title: '账户变更', icon: 'form' }
      },
      {
        path: 'infoComment',
        name: 'InfoComment',
        component: () => import('@/views/check/infoComment'),
        meta: { title: '资讯评论', icon: 'form' }
      },
      {
        path: 'orderComment',
        name: 'orderComment',
        component: () => import('@/views/check/orderComment'),
        meta: { title: '订单评论', icon: 'form' }
      }
    ]
  },

  {
    path: '/account',
    component: Layout,
    meta: { title: '账单管理', icon: 'form' },
    children: [
      {
        path: 'custome',
        name: 'Custome',
        component: () => import('@/views/account/custome'),
        meta: { title: '顾客账单', icon: 'form' }
      },
      {
        path: 'employee',
        name: 'Employee',
        component: () => import('@/views/account/employee'),
        meta: { title: '员工账单', icon: 'form' }
      },
      {
        path: 'system',
        name: 'System',
        component: () => import('@/views/account/system'),
        meta: { title: '系统账单', icon: 'form' }
      }
    ]
  },

  {
    path: '/waiter',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Waiter',
        component: () => import('@/views/waiter/index'),
        meta: { title: '员工管理', icon: 'form' }
      }
    ]
  },

  {
    path: '/custome',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Custome',
        component: () => import('@/views/custome/index'),
        meta: { title: '顾客管理', icon: 'form' }
      }
    ]
  },

  {
    path: '/info',
    component: Layout,
    meta: { title: '网站资讯', icon: 'form' },
    children: [
      {
        path: 'category',
        name: 'Category',
        component: () => import('@/views/info/category'),
        meta: { title: '资讯分类', icon: 'form' }
      },
      {
        path: 'article',
        name: 'Article',
        component: () => import('@/views/info/article'),
        meta: { title: '资讯信息', icon: 'form' }
      }
    ]
  },

  {
    path: '/baseConfig',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'BaseConfig',
        component: () => import('@/views/baseConfig/index'),
        meta: { title: '系统配置', icon: 'form' }
      }
    ]
  },

  {
    path: '/log',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Log',
        component: () => import('@/views/log/index'),
        meta: { title: '日志管理', icon: 'form' }
      }
    ]
  },

  {
    path: '/carousel',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Carousel',
        component: () => import('@/views/carousel/index'),
        meta: { title: '轮播管理', icon: 'form' }
      }
    ]
  },

  {
    path: '/owner',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Owner',
        component: () => import('@/views/owner/index'),
        meta: { title: '个人信息', icon: 'form' }
      }
    ]
  },



  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
